package cn.edu.scau.cmi.liuxintong;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import org.hibernate.Hibernate;
import org.hibernate.Transaction;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import cn.edu.scau.cmi.liuxintong.Singleton.Chairman;
import cn.edu.scau.cmi.liuxintong.Singleton.Marshal;
import cn.edu.scau.cmi.liuxintong.abstractFactory.Brand;
import cn.edu.scau.cmi.liuxintong.adapter.ClassAdapter;
import cn.edu.scau.cmi.liuxintong.adapter.Student;
import cn.edu.scau.cmi.liuxintong.adapter.objectAdapter;
import cn.edu.scau.cmi.liuxintong.consistentComposite.ConsistentComponent;
import cn.edu.scau.cmi.liuxintong.consistentComposite.ConsistentComposite;
import cn.edu.scau.cmi.liuxintong.consistentComposite.ConsistetPerson;
import cn.edu.scau.cmi.liuxintong.factory.BeefMeatFactory;
import cn.edu.scau.cmi.liuxintong.factory.ChickenMeatFactory;
import cn.edu.scau.cmi.liuxintong.factory.PorkMeatFactory;
import cn.edu.scau.cmi.liuxintong.interProgramming.GraduateStudent;
import cn.edu.scau.cmi.liuxintong.interProgramming.UndergraduateStudent;
import cn.edu.scau.cmi.liuxintong.safeComposite.SafeComponent;
import cn.edu.scau.cmi.liuxintong.safeComposite.SafeComposite;
import cn.edu.scau.cmi.liuxintong.safeComposite.SafePerson;
import cn.edu.scau.cmi.liuxintong.simpleFactoryMeyhod.MeatFactory;
import cn.edu.scau.cmi.liuxintong.spring.ApplicationContextUtil;
import javafx.application.Application;
import javafx.beans.value.ObservableValue;
import javafx.collections.FXCollections;
import javafx.event.Event;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ChoiceBox;
import javafx.scene.control.Label;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;
import javafx.scene.effect.DropShadow;
import javafx.scene.layout.AnchorPane;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.FontPosture;
import javafx.scene.text.Text;
import javafx.stage.Stage;
import cn.edu.scau.cmi.liuxintong.*;
public class ComprehensiveExperiment extends Application {
	Class<?> cls;
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		 launch(args);
	}
	@Override
		public void start(Stage primaryStage) throws Exception {
			AnchorPane anchorPane = new AnchorPane();
			DropShadow dropshadow = new DropShadow();
			dropshadow.setColor(Color.PALEVIOLETRED);
			dropshadow.setOffsetX(5.0);
			dropshadow.setOffsetY(5.0);
			dropshadow.setRadius(10.0);
			Text experimentName = new Text("体系结构实验");//ok
			experimentName.setEffect(dropshadow);
			experimentName.setFont(Font.font(" Verdana",FontPosture.ITALIC,40));
			Text function1 = new Text("1.接口编程");
			function1.setFont(Font.font(" Verdana",FontPosture.ITALIC,20));
			Text function2 = new Text("2.单例模式");
			function2.setFont(Font.font(" Verdana",FontPosture.ITALIC,20));
			Text function3 = new Text("3.多例模式");
			function3.setFont(Font.font(" Verdana",FontPosture.ITALIC,20));
			Text function4 = new Text("4.简单工厂模式");
			function4.setFont(Font.font(" Verdana",FontPosture.ITALIC,20));
			Text function5 = new Text("5.工厂模式");
			function5.setFont(Font.font(" Verdana",FontPosture.ITALIC,20));
			Text function6 = new Text("6.抽象工厂模式");
			function6.setFont(Font.font(" Verdana",FontPosture.ITALIC,20));
			Text function7 = new Text("7.类适配器");
			function7.setFont(Font.font(" Verdana",FontPosture.ITALIC,20));
			Text function8 = new Text("8.对象模式");
			function8.setFont(Font.font(" Verdana",FontPosture.ITALIC,20));
			Text function9 = new Text("9.安全组合");
			function9.setFont(Font.font(" Verdana",FontPosture.ITALIC,20));
			Text function10 = new Text("10.一致性组合");
			function10.setFont(Font.font(" Verdana",FontPosture.ITALIC,20));
			Text function11 = new Text("11.Hibernate框架");
			function11.setFont(Font.font(" Verdana",FontPosture.ITALIC,20));
			Text function12 = new Text("12.Spring基本使用");
			function12.setFont(Font.font(" Verdana",FontPosture.ITALIC,20));
			Text function13 = new Text("13.Spring管理DAO");
			function13.setFont(Font.font(" Verdana",FontPosture.ITALIC,20));
		   String[] greetings=new String[] {"请选择实现功能","1.接口编程","2.单例模式","3.多例模式","4.简单工厂模式","5.工厂模式","6.抽象工厂模式"
			,"7.类适配器","8.对象模式","9.安全组合","10.一致性组合","11.Hibernate框架","12.Spring基本使用","13.Spring管理DAO"};
		    ChoiceBox<String> choiceBox = new ChoiceBox((FXCollections.observableArrayList("请选择实现功能","1.接口编程","2.单例模式","3.多例模式","4.简单工厂模式","5.工厂模式","6.抽象工厂模式"
		    ,"7.类适配器","8.对象模式","9.安全组合","10.一致性组合","11.Hibernate框架","12.Spring基本使用","13.Spring管理DAO")));
		    choiceBox.getSelectionModel().select(0);
			TextField textField = new TextField();
			//TextArea textArea = new TextArea();
		    anchorPane.getChildren().addAll(experimentName,textField,choiceBox,function1,function2,function3,function4,function5,function6
		    ,function7,function8,function9,function10,function11,function12,function13);
			choiceBox.getSelectionModel().selectedIndexProperty().addListener(
		    		(ObservableValue<? extends Number> ov,
		    				Number old_val,Number new_val)->{
		    					switch(greetings[new_val.intValue()]) {
		    					case "请选择实现功能":
		    					case "1.接口编程":
		    						function1();
		    						break;
		    					case "2.单例模式":
		    						function2();
		    						break;
		    					case "3.多例模式":
		    						function2();
		    						break;
		    					case "4.简单工厂模式":
		    						function4();
		    						break;
		    					case "5.工厂模式":
		    						function5();
		    						break;
		    					case "6.抽象工厂模式":
		    						function6();
		    						break;
		    					case "7.类适配器":
		    						function7();
		    						break;
		    					case "8.对象模式":
		    						function8();
		    						break;
		    					case "9.安全组合":
		    						function9();
		    						break;
		    					case "10.一致性组合":
		    						function10();
		    						break;
		    					case "11.Hibernate框架":
		    						function11();
		    						break;
		    					case "12.Spring基本使用":
		    						function12();
		    						break;
		    					case "13.Spring管理DAO":
		    						function13();
		    						break;
		    					}
		    				});
		     AnchorPane.setLeftAnchor(experimentName, 275.0);
			 AnchorPane.setBottomAnchor(experimentName,400.0);//下
			 AnchorPane.setLeftAnchor(function1, 300.0);
			 AnchorPane.setBottomAnchor(function1,370.0);//下
			 AnchorPane.setLeftAnchor(function2, 300.0);
			 AnchorPane.setBottomAnchor(function2,350.0);//下
			 AnchorPane.setLeftAnchor(function3, 300.0);
			 AnchorPane.setBottomAnchor(function3,330.0);//下
			 AnchorPane.setLeftAnchor(function4, 300.0);
			 AnchorPane.setBottomAnchor(function4,310.0);//下
			 AnchorPane.setLeftAnchor(function5, 300.0);
			 AnchorPane.setBottomAnchor(function5,290.0);//下
			 AnchorPane.setLeftAnchor(function6, 300.0);
			 AnchorPane.setBottomAnchor(function6,270.0);//下
			 AnchorPane.setLeftAnchor(function7, 300.0);
			 AnchorPane.setBottomAnchor(function7,250.0);//下
			 AnchorPane.setLeftAnchor(function8, 300.0);
			 AnchorPane.setBottomAnchor(function8,230.0);//下
			 AnchorPane.setLeftAnchor(function9, 300.0);
			 AnchorPane.setBottomAnchor(function9,210.0);//下
			 AnchorPane.setLeftAnchor(function10, 300.0);
			 AnchorPane.setBottomAnchor(function10,190.0);//下
			 AnchorPane.setLeftAnchor(function11, 300.0);
			 AnchorPane.setBottomAnchor(function11,170.0);//下
			 AnchorPane.setLeftAnchor(function12, 300.0);
			 AnchorPane.setBottomAnchor(function12,150.0);//下
			 AnchorPane.setLeftAnchor(function13, 300.0);
			 AnchorPane.setBottomAnchor(function13,130.0);//下
			 AnchorPane.setLeftAnchor(textField, 140.0);
			 AnchorPane.setBottomAnchor(textField,470.0);//下
			 AnchorPane.setLeftAnchor( choiceBox, 300.0);
			 AnchorPane.setBottomAnchor( choiceBox,100.0);//下
			 primaryStage.setScene(new Scene(anchorPane, 800,450));
		     primaryStage.show();
	}
    public void function1() {
    	TextArea textArea = new TextArea();
    	Stage secondaryStage=new Stage();
    	AnchorPane anchorPane = new AnchorPane();
		DropShadow dropshadow = new DropShadow();
		dropshadow.setColor(Color.PALEVIOLETRED);
		dropshadow.setOffsetX(5.0);
		dropshadow.setOffsetY(5.0);
		dropshadow.setRadius(10.0);
		Text experimentName = new Text("接口编程实验");//ok
		experimentName.setEffect(dropshadow);
		experimentName.setFont(Font.font(" Verdana",FontPosture.ITALIC,40));
		TextField textField = new TextField();
		textArea.setPrefHeight(330);
		textArea.setPrefWidth(780);
		 Button GraduateStudent = new Button("研究生");
		  Button UndergraduateStudent = new Button("本科生");
		  GraduateStudent.setOnAction(new EventHandler() {
		  public void handle(Event event) {
		  textArea.appendText(new GraduateStudent().learning()+"\n");
		  }});
		  UndergraduateStudent.setOnAction(new EventHandler() {
			  public void handle(Event event) {
			  textArea.appendText(new UndergraduateStudent().learning()+"\n");
			  }});
		  anchorPane.getChildren().addAll(experimentName,textField,textArea,GraduateStudent,UndergraduateStudent);
	     AnchorPane.setLeftAnchor(experimentName, 275.0);
		 AnchorPane.setBottomAnchor(experimentName,400.0);//下
		 AnchorPane.setLeftAnchor(textField, 140.0);
		 AnchorPane.setLeftAnchor(GraduateStudent,200.0);
		 AnchorPane.setBottomAnchor(GraduateStudent,350.0);//下
		 AnchorPane.setLeftAnchor( UndergraduateStudent, 450.0);
		 AnchorPane.setBottomAnchor( UndergraduateStudent,350.0);//下
		 AnchorPane.setBottomAnchor(textField,470.0);//下
		 AnchorPane.setLeftAnchor(textArea, 10.0);
		 AnchorPane.setBottomAnchor(textArea,10.0);
		 secondaryStage.setScene(new Scene(anchorPane, 800,450));
		 secondaryStage.show();
    }
    int count1=0;
	int count2=0;
    public void function2() {
    	Stage secondaryStage=new Stage();
    	AnchorPane anchorPane = new AnchorPane();
        Chairman instance = null;
        Marshal testLis = null;
		 Label label1 = new Label("请输入主席名称:");
		 Label label2 = new Label("请输入元帅名称:");
		 TextField textField1 = new TextField();
		 TextField textField2 = new TextField();
		 Button button1 = new Button("创建");
		 Button button2 = new Button("创建");
		 TextArea textArea = new TextArea();
	        textArea.setPrefHeight(380);
	        textArea.setPrefWidth(680);
		 anchorPane.getChildren().addAll(label1,label2,textField1,textField2,button1,button2,textArea);
		 button1.setOnAction(new EventHandler() {
				public void handle(Event event) {
					 if(textField1.getText()!=null&&!textField1.getText().isEmpty()) {
						if(count1==0) {
							instance.getInstance(textField1.getText());
						    count1++;
						 textArea.appendText(textField1.getText()+"cn.edu.scau.cmi.liuxintong.Singleton.Chairman\n");
					 }
					 else {
						    textArea.appendText("单例模式下已有对象创建，无法创建新对象了！你现在获得的对象是：\n");
						    textArea.appendText(instance.getName()+"cn.edu.scau.cmi.liuxintong.Singleton.Chairman\n");
					 }
				}
				}
			});
		 button2.setOnAction(new EventHandler() {
			public void handle(Event event) {
				 if(textField2.getText()!=null&&!textField2.getText().isEmpty()) {
					if(count2<10) {
						if(testLis.addMarshal(textField2.getText())==-1) {//无该元帅且没到10个
							count2++;
							 textArea.appendText(textField2.getText()+"cn.edu.scau.cmi.liuxintong.Singleton.Chairman\n");
						}
						else {
							 textArea.appendText("多例模式下已创建该对象，无法创建重复对象了！\n");
				 }
					}
				 else {
					    textArea.appendText("多例模式下10个对象创建，无法创建新对象了！\n");
				 }
				 }
			}
		});
		
		//界面布局
		 AnchorPane.setLeftAnchor(label1, 10.0);
		 AnchorPane.setBottomAnchor(label1,480.0);//下
		 AnchorPane.setLeftAnchor(textField1, 140.0);
		 AnchorPane.setBottomAnchor(textField1,470.0);//下
		 AnchorPane.setLeftAnchor(button1,350.0);
		 AnchorPane.setBottomAnchor(button1,470.0);//下
		 AnchorPane.setLeftAnchor(label2, 10.0);
		 AnchorPane.setBottomAnchor(label2,400.0);//下
		 AnchorPane.setLeftAnchor(textField2, 140.0);
		 AnchorPane.setBottomAnchor(textField2,400.0);//下
		 AnchorPane.setLeftAnchor(button2,350.0);
		 AnchorPane.setBottomAnchor(button2,400.0);//下
		 AnchorPane.setLeftAnchor(textArea, 10.0);
		 AnchorPane.setBottomAnchor(textArea,10.0);
		 secondaryStage.setScene(new Scene(anchorPane, 700, 500));
		 secondaryStage.show();
    }
    public void function4() {
    	Stage secondaryStage=new Stage();
    	AnchorPane anchorPane = new AnchorPane();
		 Label label = new Label("请输入肉类名称:");
		 TextField textField = new TextField();
		 Button button = new Button("创建");
		 TextArea textArea = new TextArea();
	        textArea.setPrefHeight(380);
	        textArea.setPrefWidth(680);
		 anchorPane.getChildren().addAll(label,textField,button,textArea);
		 button.setOnAction(new EventHandler() {
				public void handle(Event event) {
					 if(textField.getText()!=null&&!textField.getText().isEmpty()) {
						 MeatFactory meat=new MeatFactory();
						 textArea.appendText(meat.getMeet(textField.getText()));
						 textArea.appendText("\n");
				}
				}
			});
		//界面布局
		 AnchorPane.setLeftAnchor(label, 10.0);
		 AnchorPane.setBottomAnchor(label,480.0);//下
		 AnchorPane.setLeftAnchor(textField, 140.0);
		 AnchorPane.setBottomAnchor(textField,470.0);//下
		 AnchorPane.setLeftAnchor(button,350.0);
		 AnchorPane.setBottomAnchor(button,470.0);//下
		 AnchorPane.setLeftAnchor(textArea, 10.0);
		 AnchorPane.setBottomAnchor(textArea,10.0);
		 secondaryStage.setScene(new Scene(anchorPane, 700, 500));
		 secondaryStage.show();
    }
    public void function5() {
    	Stage secondaryStage=new Stage();
    	AnchorPane anchorPane = new AnchorPane();
		 Label label = new Label("请输入肉类名称:");
		 TextField textField = new TextField();
		 Button button = new Button("创建");
		 TextArea textArea = new TextArea();
	        textArea.setPrefHeight(380);
	        textArea.setPrefWidth(680);
		 anchorPane.getChildren().addAll(label,textField,button,textArea);
		 button.setOnAction(new EventHandler() {
				public void handle(Event event) {
					 if(textField.getText()!=null&&!textField.getText().isEmpty()) {
						 String meat=textField.getText();
						if(meat.compareTo("prok")==0) {
							PorkMeatFactory prok=new PorkMeatFactory();
							 textArea.appendText(prok.getmeat());
							 textArea.appendText("\n");
						}
						else if(meat.compareTo("beef")==0) {
							BeefMeatFactory beef=new BeefMeatFactory();
							 textArea.appendText(beef.getmeat());
							 textArea.appendText("\n");
						}
						else if(meat.compareTo("chicken")==0) {
							ChickenMeatFactory chicken=new ChickenMeatFactory();
							 textArea.appendText(chicken.getmeat());
							 textArea.appendText("\n");
						}
						else {
							textArea.appendText("没有这种肉");
							textArea.appendText("\n");
						}
						
				}
				}
			});
		//界面布局
		 AnchorPane.setLeftAnchor(label, 10.0);
		 AnchorPane.setBottomAnchor(label,480.0);//下
		 AnchorPane.setLeftAnchor(textField, 140.0);
		 AnchorPane.setBottomAnchor(textField,470.0);//下
		 AnchorPane.setLeftAnchor(button,350.0);
		 AnchorPane.setBottomAnchor(button,470.0);//下
		 AnchorPane.setLeftAnchor(textArea, 10.0);
		 AnchorPane.setBottomAnchor(textArea,10.0);
		 secondaryStage.setScene(new Scene(anchorPane, 700, 500));
		 secondaryStage.show();
    }
    public void function6() {
    	Stage secondaryStage=new Stage();
    	 AnchorPane anchorPane = new AnchorPane();
		 Label label = new Label("请输入肉类名称:");
		 TextField textField = new TextField();
		 Button button = new Button("创建");
		 TextArea textArea = new TextArea();
	        textArea.setPrefHeight(380);
	        textArea.setPrefWidth(680);
		 anchorPane.getChildren().addAll(label,textField,button,textArea);
		 button.setOnAction(new EventHandler() {
				public void handle(Event event) {
					 if(textField.getText()!=null&&!textField.getText().isEmpty()) {
						 String meat=textField.getText();
						String getmeat[]=meat.split("'s ");
						Brand brand=new Brand();
						 textArea.appendText(brand.getBrand(getmeat[0], getmeat[1]));
						 textArea.appendText("\n");
				}
				}
			});
		//界面布局
		 AnchorPane.setLeftAnchor(label, 10.0);
		 AnchorPane.setBottomAnchor(label,480.0);//下
		 AnchorPane.setLeftAnchor(textField, 140.0);
		 AnchorPane.setBottomAnchor(textField,470.0);//下
		 AnchorPane.setLeftAnchor(button,350.0);
		 AnchorPane.setBottomAnchor(button,470.0);//下
		 AnchorPane.setLeftAnchor(textArea, 10.0);
		 AnchorPane.setBottomAnchor(textArea,10.0);
		 secondaryStage.setScene(new Scene(anchorPane, 700, 500));
		 secondaryStage.show();
    }
    public void function7() {
    	 Stage secondaryStage=new Stage();
    	 AnchorPane anchorPane = new AnchorPane();
		 ClassAdapter classadapter=new ClassAdapter();
		 Label label1 = new Label("请输入学生名称:");
		 Label label2=new Label("请输入学生学号：");
		 TextField textField1 = new TextField();
		 TextField textField2 = new TextField();
		 Button button = new Button("创建");
		 TextArea textArea = new TextArea();
	        textArea.setPrefHeight(380);
	        textArea.setPrefWidth(680);
		 anchorPane.getChildren().addAll(label1,label2,textField1,textField2,button,textArea);
		 button.setOnAction(new EventHandler() {
				public void handle(Event event) {
				Student student=new Student();
				student.setName(textField1.getText());
				student.setId(Integer.parseInt(textField2.getText()));
				classadapter.insertStudent(student);
				ArrayList<Student> students=new ArrayList<Student>();
				students=classadapter.getStudents();
				textArea.appendText("现在已有的学生名单为：\n");
				for(int i=0;i<students.size();i++)
				 textArea.appendText(students.get(i).getId()+"      "+students.get(i).getName()+"\n");
				}
				
			});
		//界面布局
		 AnchorPane.setLeftAnchor(label1, 10.0);
		 AnchorPane.setBottomAnchor(label1,480.0);//下
		 AnchorPane.setLeftAnchor(textField1, 140.0);
		 AnchorPane.setBottomAnchor(textField1,470.0);//下
		 AnchorPane.setLeftAnchor(label2, 10.0);
		 AnchorPane.setBottomAnchor(label2,400.0);//下
		 AnchorPane.setLeftAnchor(textField2, 140.0);
		 AnchorPane.setBottomAnchor(textField2,400.0);//下
		 AnchorPane.setLeftAnchor(button,350.0);
		 AnchorPane.setBottomAnchor(button,400.0);//下
		 AnchorPane.setLeftAnchor(textArea, 10.0);
		 AnchorPane.setBottomAnchor(textArea,10.0);
		 secondaryStage.setScene(new Scene(anchorPane, 700, 500));
		 secondaryStage.show();
    }
    public void function8() {
    	Stage secondaryStage=new Stage();
    	AnchorPane anchorPane = new AnchorPane();
		 objectAdapter objectadapter=new objectAdapter();
		 Label label1 = new Label("请输入学生名称:");
		 Label label2=new Label("请输入学生学号：");
		 TextField textField1 = new TextField();
		 TextField textField2 = new TextField();
		 Button button = new Button("创建");
		 TextArea textArea = new TextArea();
	        textArea.setPrefHeight(380);
	        textArea.setPrefWidth(680);
		 anchorPane.getChildren().addAll(label1,label2,textField1,textField2,button,textArea);
		 button.setOnAction(new EventHandler() {
				public void handle(Event event) {
				Student student=new Student();
				student.setName(textField1.getText());
				student.setId(Integer.parseInt(textField2.getText()));
				objectadapter.insertStudent(student);
				ArrayList<Student> students=new ArrayList<Student>();
				students=objectadapter.getStudents();
				textArea.appendText("现在已有的学生名单为：\n");
				for(int i=0;i<students.size();i++)
				 textArea.appendText(students.get(i).getId()+"      "+students.get(i).getName()+"\n");
				}
				
			});
		//界面布局
		 AnchorPane.setLeftAnchor(label1, 10.0);
		 AnchorPane.setBottomAnchor(label1,480.0);//下
		 AnchorPane.setLeftAnchor(textField1, 140.0);
		 AnchorPane.setBottomAnchor(textField1,470.0);//下
		 AnchorPane.setLeftAnchor(label2, 10.0);
		 AnchorPane.setBottomAnchor(label2,400.0);//下
		 AnchorPane.setLeftAnchor(textField2, 140.0);
		 AnchorPane.setBottomAnchor(textField2,400.0);//下
		 AnchorPane.setLeftAnchor(button,350.0);
		 AnchorPane.setBottomAnchor(button,400.0);//下
		 AnchorPane.setLeftAnchor(textArea, 10.0);
		 AnchorPane.setBottomAnchor(textArea,10.0);
		 secondaryStage.setScene(new Scene(anchorPane, 700, 500));
		 secondaryStage.show();
    }
    SafePerson[] safeperson=new SafePerson[100];
	SafeComposite[] safeteam=new SafeComposite[100];
	int safepersonNumber=0;
	int safeteamNumber=0;
	String name;
    public void function9() {
    	Stage secondaryStage=new Stage();
    	TextArea textArea = new TextArea();
    	AnchorPane anchorPane = new AnchorPane();
		DropShadow dropshadow = new DropShadow();
		dropshadow.setColor(Color.PALEVIOLETRED);
		dropshadow.setOffsetX(5.0);
		dropshadow.setOffsetY(5.0);
		dropshadow.setRadius(10.0);
		Text experimentName = new Text("安全组织实验");//ok
		experimentName.setEffect(dropshadow);
		experimentName.setFont(Font.font(" Verdana",FontPosture.ITALIC,40));
	   String[] greetings=new String[] {"请选择实现功能","1.创建的个人的名字","2.组织的名字",
	    "3.输入组织的名字下的个人（输入格式例：组织名字   个人名字1   个人名字2）","4.输出组织下的人员名单","5.删除组织下的人员（输入格式例：组织名字   个人名字1   个人名字2）"};
	    ChoiceBox<String> choiceBox = new ChoiceBox((FXCollections.observableArrayList("请选择实现功能","1.创建的个人的名字","2.组织的名字",
	    "3.输入组织的名字下的个人（输入格式例：组织名字   个人名字1   个人名字2）","4.输出组织下的人员名单","5.删除组织下的人员（输入格式例：组织名字   个人名字1   个人名字2）")));
	    choiceBox.getSelectionModel().select(0);
		TextField textField = new TextField();
		textArea.setPrefHeight(330);
	    textArea.setPrefWidth(780);
	    anchorPane.getChildren().addAll(experimentName,textField,choiceBox,textArea);
		choiceBox.getSelectionModel().selectedIndexProperty().addListener(
	    		(ObservableValue<? extends Number> ov,
	    				Number old_val,Number new_val)->{
	    					switch(greetings[new_val.intValue()]) {
	    					case "请选择实现功能":
	    						textArea.appendText("请选择实现功能\n");
	    						break;
	    					case "1.创建的个人的名字":
	    						name=textField.getText();
	    						if(safepersonNumber>=100) {
	    							textArea.appendText("个人对象已建立满");
	    						}
	    						else {
	    							safeperson[safepersonNumber]=new SafePerson();
	    							safeperson[safepersonNumber].setName(name);
	    							safepersonNumber++;
	    							textArea.appendText("个人对象"+name+"已创建\n");
	    						}
	    						break;
	    					case "2.组织的名字":
	    						name=textField.getText();
	    						  if(safeteamNumber>=100) {
	    							  textArea.appendText("组织对象已建立满");
	    						    }
	    						    else {
	    						    	safeteam[safeteamNumber]=new SafeComposite();
	    						    	safeteam[safeteamNumber].setName(name);
	    						    	safeteamNumber++;
	    						    	textArea.appendText("组织对象"+name+"已创建\n"); 
	    						    }
	    						   
	    							break;
	    					case "3.输入组织的名字下的个人（输入格式例：组织名字   个人名字1   个人名字2）":
	    						name=textField.getText();
	    						String getname[]=name.split(" ");
	    						int theteam = 0;
	    						int [] thePerson=new int[getname.length];
	    						for(int j=0;j<=safeteamNumber;j++) {
	    							if(safeteam[j].getName().equals(getname[0]))
	    							theteam=j;
	    							break;
	    							}
	    						for(int j=1;j<getname.length;j++) {      
	    			            for(int i=0;i<=safepersonNumber;i++) {
	    			            if(safeperson[i].getName().equals(getname[j])) {
	    			            thePerson[j-1]=i;
	    			            break;
	    			            }
	    			            }
	    			            }
	    						for(int j=0;j<thePerson.length;j++) {
	    			        		safeteam[theteam].addChild(safeperson[thePerson[j]]);
	    			        	}
	    						textArea.appendText("已插入\n"); 
	    			        	break;
	    					case "4.输出组织下的人员名单":
	    						name=textField.getText();
	    						int thisteam = 0;
	    						  for(int j=0;j<=safeteam.length;j++) {
	    								if(safeteam[j].getName().equals(name))
	    									thisteam=j;
	    								break;
	    						}
	    						  Set<SafeComponent> children = safeteam[thisteam].getChildren();
	    						  Iterator<SafeComponent> teamChildrenIterator =  children .iterator();
	    						  while (teamChildrenIterator.hasNext()) {
	    								SafeComponent thisperson = teamChildrenIterator.next();
	    								textArea.appendText(thisperson.getName()+"\n");
	    					        }
	    						  break;
	    					case "5.删除组织下的人员（输入格式例：组织名字   个人名字1   个人名字2）":
	    						name=textField.getText();
	    						String getname1[]=name.split(" ");
	    						int theteam1 = 0;
	    						int [] thePerson1=new int[getname1.length];
	    						for(int j=0;j<=safeteamNumber;j++) {
	    							if(safeteam[j].getName().equals(getname1[0]))
	    							theteam=j;
	    							break;
	    							}
	    						 for(int j=1;j<getname1.length;j++) {      
	    				          for(int i=0;i<=safepersonNumber;i++) {
	    				            		if(safeperson[i].getName().equals(getname1[j])) {
	    				            			thePerson1[j-1]=i;
	    				            			break;
	    				           }
	    				          }
	    				          }
	    						 for(int j=0;j<thePerson1.length;j++) {
	    			            		safeteam[theteam1].removeChild(safeperson[thePerson1[j]]);
	    			             }
	    						 textArea.appendText("已删除\n"); 
	    			            	break; 
	    					}
	    				});
	     AnchorPane.setLeftAnchor(experimentName, 275.0);
		 AnchorPane.setBottomAnchor(experimentName,400.0);//下
		 AnchorPane.setLeftAnchor(textField, 580.0);
		 AnchorPane.setBottomAnchor(textField,350.0);//下
		 AnchorPane.setLeftAnchor( choiceBox, 0.0);
		 AnchorPane.setBottomAnchor( choiceBox,350.0);//下
		 AnchorPane.setLeftAnchor(textArea, 10.0);
		 AnchorPane.setBottomAnchor(textArea,10.0);
		 secondaryStage.setScene(new Scene(anchorPane, 800,450));
		 secondaryStage.show();
    }
    ConsistentComponent[] person=new ConsistetPerson[100];
	ConsistentComponent[] team=new ConsistentComposite[100];
	int personNumber=0;
	int teamNumber=0;    
    public void function10() {
    	Stage secondaryStage=new Stage();
    	TextArea textArea = new TextArea();
    	AnchorPane anchorPane = new AnchorPane();
		DropShadow dropshadow = new DropShadow();
		dropshadow.setColor(Color.PALEVIOLETRED);
		dropshadow.setOffsetX(5.0);
		dropshadow.setOffsetY(5.0);
		dropshadow.setRadius(10.0);
		Text experimentName = new Text("一致性组织实验");//ok
		experimentName.setEffect(dropshadow);
		experimentName.setFont(Font.font(" Verdana",FontPosture.ITALIC,40));
	   String[] greetings=new String[] {"请选择实现功能","1.创建的个人的名字","2.组织的名字",
	    "3.输入组织的名字下的个人（输入格式例：组织名字   个人名字1   个人名字2）","4.输出组织下的人员名单","5.删除组织下的人员（输入格式例：组织名字   个人名字1   个人名字2）"};
	    ChoiceBox<String> choiceBox = new ChoiceBox((FXCollections.observableArrayList("请选择实现功能","1.创建的个人的名字","2.组织的名字",
	    "3.输入组织的名字下的个人（输入格式例：组织名字   个人名字1   个人名字2）","4.输出组织下的人员名单","5.删除组织下的人员（输入格式例：组织名字   个人名字1   个人名字2）")));
	    choiceBox.getSelectionModel().select(0);
		TextField textField = new TextField();
		textArea.setPrefHeight(330);
	    textArea.setPrefWidth(780);
	    anchorPane.getChildren().addAll(experimentName,textField,choiceBox,textArea);
		choiceBox.getSelectionModel().selectedIndexProperty().addListener(
	    		(ObservableValue<? extends Number> ov,
	    				Number old_val,Number new_val)->{
	    					switch(greetings[new_val.intValue()]) {
	    					case "请选择实现功能":
	    						textArea.appendText("请选择实现功能\n");
	    						break;
	    					case "1.创建的个人的名字":
	    						name=textField.getText();
	    						if(personNumber>=100) {
	    							textArea.appendText("个人对象已建立满");
	    						}
	    						else {
	    							person[personNumber]=new ConsistetPerson();
	    							((ConsistetPerson)person[personNumber]).setName(name);
	    							personNumber++;
	    							textArea.appendText("个人对象"+name+"已创建\n");
	    						}
	    						break;
	    					case "2.组织的名字":
	    						name=textField.getText();
	    						if(teamNumber>=100) {
	    							textArea.appendText("组织对象已建立满");
	    					    }
	    					    else {
	    					    	team[teamNumber]=new ConsistentComposite();
	    					    	((ConsistentComposite)team[teamNumber]).setName(name);
	    					        teamNumber++;
	    					        textArea.appendText("组织对象"+name+"已创建\n"); 
	    					    }
	    					    
	    						break;
	    					case "3.输入组织的名字下的个人（输入格式例：组织名字   个人名字1   个人名字2）":
	    						name=textField.getText();
	    						String getname[]=name.split(" ");
	    						int theteam = 0;
	    						int [] thePerson=new int[getname.length];
	    			            for(int j=0;j<=teamNumber;j++) {
	    							if(team[j].getName().equals(getname[0]))
	    							theteam=j;
	    							break;
	    							}
	    			            for(int j=1;j<getname.length;j++) {      
	    			            	for(int i=0;i<=personNumber;i++) {
	    			            		if(person[i].getName().equals(getname[j])) {
	    			            			thePerson[j-1]=i;
	    			            			break;
	    			            			}
	    			            	}
	    			            	}
	    			            	for(int j=0;j<thePerson.length;j++) {
	    			            		team[theteam].add(person[thePerson[j]]);
	    			            	}
	    			            	textArea.appendText("已插入\n"); 
	    			            	break;
	    					case "4.输出组织下的人员名单":
	    						name=textField.getText();
	    						int thisteam = 0;
	    						if(team.length==0)
	    							textArea.appendText("该组织内无人");
	    						  for(int j=0;j<=team.length;j++) {
	    								if(team[j].getName().equals(name))
	    									thisteam=j;
	    								break;
	    						}
	    					Set<ConsistentComponent> teamChildren = team[thisteam].get();
	    				    Iterator<ConsistentComponent> teamChildrenIterator =  teamChildren .iterator();
	    				    while (teamChildrenIterator.hasNext()) {
	    						ConsistentComponent thisperson = teamChildrenIterator.next();
	    						textArea.appendText(thisperson.getName());
	    			        }
	    				    break;
	    					case "5.删除组织下的人员（输入格式例：组织名字   个人名字1   个人名字2）":
	    						name=textField.getText();
	    						String getname1[]=name.split(" ");
	    						int theteam1 = 0;
	    						int [] thePerson1=new int[getname1.length];
	    						for(int j=0;j<=teamNumber;j++) {
	    							if(team[j].getName().equals(getname1[0]))
	    							theteam=j;
	    							break;
	    							}
	    						 for(int j=1;j<getname1.length;j++) {      
	    				            	for(int i=0;i<=personNumber;i++) {
	    				            		if(person[i].getName().equals(getname1[j])) {
	    				            			thePerson1[j-1]=i;
	    				            			break;
	    				            			}
	    				            		
	    				          }
	    				          }
	    						 for(int j=0;j<thePerson1.length;j++) {
	    			            		team[theteam1].delete(person[thePerson1[j]]);
	    			            	}
	    						 textArea.appendText("已删除\n"); 
	    			            	break;
	    					}
	    				});
	     AnchorPane.setLeftAnchor(experimentName, 275.0);
		 AnchorPane.setBottomAnchor(experimentName,400.0);//下
		 AnchorPane.setLeftAnchor(textField, 580.0);
		 AnchorPane.setBottomAnchor(textField,350.0);//下
		 AnchorPane.setLeftAnchor( choiceBox, 0.0);
		 AnchorPane.setBottomAnchor( choiceBox,350.0);//下
		 AnchorPane.setLeftAnchor(textArea, 10.0);
		 AnchorPane.setBottomAnchor(textArea,10.0);
		 secondaryStage.setScene(new Scene(anchorPane, 800,450));
		 secondaryStage.show();
    }
    String read;
    static TextArea HibernatatextArea = new TextArea();
    public void function11() {
    	Stage secondaryStage=new Stage();
    	AnchorPane anchorPane = new AnchorPane();
		DropShadow dropshadow = new DropShadow();
		dropshadow.setColor(Color.PALEVIOLETRED);
		dropshadow.setOffsetX(5.0);
		dropshadow.setOffsetY(5.0);
		dropshadow.setRadius(10.0);
		Text experimentName = new Text("Hibernate框架实验");//ok
		experimentName.setEffect(dropshadow);
		experimentName.setFont(Font.font(" Verdana",FontPosture.ITALIC,40));
	    String[] greetings=new String[] {"请选择实现功能","1.添加学生","2.修改学生","3.删除学生","4.添加教师"
	    ,"5.修改教师","6.删除教师","7.学生选择指导教师","8.学生修改指导教师","9.教师选择被指导的学生",
	    "10.教师修改被指导的学生","11.显示学生和教师信息"};
	    ChoiceBox<String> choiceBox = new ChoiceBox((FXCollections.observableArrayList("请选择实现功能","1.添加学生","2.修改学生","3.删除学生","4.添加教师"
	    ,"5.修改教师","6.删除教师","7.学生选择指导教师","8.学生修改指导教师","9.教师选择被指导的学生",
	    "10.教师修改被指导的学生","11.显示学生和教师信息")));
	    choiceBox.getSelectionModel().select(0);
		TextField textField = new TextField();
		HibernatatextArea.setPrefHeight(330);
		HibernatatextArea.setPrefWidth(780);
	    anchorPane.getChildren().addAll(experimentName,textField,choiceBox,HibernatatextArea);
		choiceBox.getSelectionModel().selectedIndexProperty().addListener(
	    		(ObservableValue<? extends Number> ov,
	    				Number old_val,Number new_val)->{
	    					HibernataClient hibernataClient;
							switch(greetings[new_val.intValue()]) {
	    					case "请选择实现功能":
	    						HibernatatextArea.appendText("请选择实现功能\n");
	    						break;
	    					case "1.添加学生":
	    						HibernatatextArea.appendText("请输入要添加学生姓名:\n");
	    						read=textField.getText();
	    						HibernataClient.newStudent(read);
	    						HibernatalistStudents();
	    				        break; 
	    					case "2.修改学生":
	    						HibernatatextArea.appendText("请输入要修改学生id和姓名:\n");
	    						 read=textField.getText();
	    				          String[] temp=read.split(" ");
	    				          HibernataClient.changeStudent(temp[0],temp[1]);
	    				          HibernatalistStudents();
	    				          break;
	    					case "3.删除学生":
	    						HibernatatextArea.appendText("请输入要删除学生id:\n");
	    						  read=textField.getText();
	    						  HibernataClient.delectStudent(read);
	    						  HibernatalistStudents();
	    				          break;
	    					case "4.添加教师":
	    						HibernatatextArea.appendText("请输入要添加老师姓名:\n");
	    						 read=textField.getText();
	    						 HibernataClient.newTeacher(read);
	    						 HibernatalistTeacher();
	    				          break;
	    					case "5.修改教师":
	    						HibernatatextArea.appendText("请输入要修改老师id和姓名:\n");
	    						read=textField.getText();
	    			            String[] temp1=read.split(" ");
	    			            HibernataClient.changeTeacher(temp1[0],temp1[1]);
	    			            HibernatalistTeacher();
	    			            break;
	    					case "6.删除教师"	:
	    						HibernatatextArea.appendText("请输入要删除老师id\n");
	    						read=textField.getText();
	    						HibernataClient. delectTeacher(read);
	    						HibernatalistTeacher();
	    				          break;
	    					case "7.学生选择指导教师":
	    						HibernatatextArea.appendText("请输入学生的id和选择老师的id\n");
	    						read=textField.getText();
	    			               String[] temp2=read.split(" ");
	    			               HibernataClient. chooseTutorTeacher(temp2[0],temp2[1]);
	    			               break;
	    					case "8.学生修改指导教师":
	    						HibernatatextArea.appendText("请输入学生的id和新指导老师的id\n");
	    						read=textField.getText();
	    			              String[] temp3=read.split(" ");
	    			              HibernataClient. changeTutorTeacher(temp3[0],temp3[1]);
	    					       break;	
	    					case "9.教师选择被指导的学生":
	    						HibernatatextArea.appendText("请输入老师id和被指导学生id\n");
	    						read=textField.getText();
	    			               String[] temp4=read.split(" ");
	    			               HibernataClient. changeBeTutorStudent(temp4[0],temp4[1]);
	    			               break;
	    					case "10.教师修改被指导的学生":
	    						HibernatatextArea.appendText("请输入老师id和需要修改被指导学生id\n");
	    						read=textField.getText();
	    			               String[] temp5=read.split(" ");
	    			               HibernataClient.changeTutorStudent(temp5[0],temp5[1]);
	    			               break;
	    					case "11.显示学生和教师信息":
	    						HibernatalistStudents();    
	    						HibernatalistTeacher();
	    		                break;
	    					}
	    				});
	     AnchorPane.setLeftAnchor(experimentName, 275.0);
		 AnchorPane.setBottomAnchor(experimentName,400.0);//下
		 AnchorPane.setLeftAnchor(textField, 450.0);
		 AnchorPane.setBottomAnchor(textField,350.0);//下
		 AnchorPane.setLeftAnchor( choiceBox, 150.0);
		 AnchorPane.setBottomAnchor( choiceBox,350.0);//下
		 AnchorPane.setLeftAnchor(HibernatatextArea, 10.0);
		 AnchorPane.setBottomAnchor(HibernatatextArea,10.0);
		 secondaryStage.setScene(new Scene(anchorPane, 800,450));
		 secondaryStage.show();
    }
    static TextArea SpringBaseUsetextArea = new TextArea();
    public void function12() {
    	Stage secondaryStage=new Stage();
    	AnchorPane anchorPane = new AnchorPane();
		DropShadow dropshadow = new DropShadow();
		dropshadow.setColor(Color.PALEVIOLETRED);
		dropshadow.setOffsetX(5.0);
		dropshadow.setOffsetY(5.0);
		dropshadow.setRadius(10.0);
		Text experimentName = new Text("Spring基本使用");//ok
		experimentName.setEffect(dropshadow);
		experimentName.setFont(Font.font(" Verdana",FontPosture.ITALIC,40));
		TextField textField = new TextField();
		SpringBaseUsetextArea.setPrefHeight(330);
		SpringBaseUsetextArea.setPrefWidth(780);
		 Button Springbaseuse = new Button("输出张三的导师");
		 Springbaseuse.setOnAction(new EventHandler() {
			  public void handle(Event event) {
				  SpringBaseUselist();
			  }});
		 anchorPane.getChildren().addAll(experimentName,textField,SpringBaseUsetextArea,Springbaseuse);
	     AnchorPane.setLeftAnchor(experimentName, 275.0);
		 AnchorPane.setBottomAnchor(experimentName,400.0);//下
		 AnchorPane.setLeftAnchor(textField, 140.0);
		 AnchorPane.setLeftAnchor( Springbaseuse, 450.0);
		 AnchorPane.setBottomAnchor( Springbaseuse,350.0);//下
		 AnchorPane.setBottomAnchor(textField,470.0);//下
		 AnchorPane.setLeftAnchor(SpringBaseUsetextArea, 10.0);
		 AnchorPane.setBottomAnchor(SpringBaseUsetextArea,10.0);
		 secondaryStage.setScene(new Scene(anchorPane, 800,450));
		 secondaryStage.show();
    }
    static TextArea StringDAOtextArea = new TextArea();
    public void function13() {
    	Stage secondaryStage=new Stage();
    	AnchorPane anchorPane = new AnchorPane();
		DropShadow dropshadow = new DropShadow();
		dropshadow.setColor(Color.PALEVIOLETRED);
		dropshadow.setOffsetX(5.0);
		dropshadow.setOffsetY(5.0);
		dropshadow.setRadius(10.0);
		Text experimentName = new Text("Spring管理DAO实验");//ok
		experimentName.setEffect(dropshadow);
		experimentName.setFont(Font.font(" Verdana",FontPosture.ITALIC,40));
	    String[] greetings=new String[] {"请选择实现功能","1.添加学生","2.修改学生","3.删除学生","4.添加教师"
	    ,"5.修改教师","6.删除教师","7.学生选择指导教师","8.学生修改指导教师","9.教师选择被指导的学生",
	    "10.教师修改被指导的学生","11.显示学生和教师信息"};
	    ChoiceBox<String> choiceBox = new ChoiceBox((FXCollections.observableArrayList("请选择实现功能","1.添加学生","2.修改学生","3.删除学生","4.添加教师"
	    ,"5.修改教师","6.删除教师","7.学生选择指导教师","8.学生修改指导教师","9.教师选择被指导的学生",
	    "10.教师修改被指导的学生","11.显示学生和教师信息")));
	    choiceBox.getSelectionModel().select(0);
		TextField textField = new TextField();
		StringDAOtextArea.setPrefHeight(330);
		StringDAOtextArea.setPrefWidth(780);
	    anchorPane.getChildren().addAll(experimentName,textField,choiceBox,StringDAOtextArea);
		choiceBox.getSelectionModel().selectedIndexProperty().addListener(
	    		(ObservableValue<? extends Number> ov,
	    				Number old_val,Number new_val)->{
	    					switch(greetings[new_val.intValue()]) {
	    					case "请选择实现功能":
	    						StringDAOtextArea.appendText("请选择实现功能\n");
	    						break;
	    					case "1.添加学生":
	    						StringDAOtextArea.appendText("请输入要添加学生姓名:\n");
	    						read=textField.getText();
	    				           SpringHibernateSessionClient.newStudent(read);
	    				           StringDAOlistStudents();
	    				           break;
	    					case "2.修改学生":
	    						StringDAOtextArea.appendText("请输入要修改学生id和姓名:\n");
	    						 read=textField.getText();
	    				          String[] temp=read.split(" ");
	    				          SpringHibernateSessionClient.changeStudent(temp[0],temp[1]);
	    				          StringDAOlistStudents();
	    				          break;
	    					case "3.删除学生":
	    						StringDAOtextArea.appendText("请输入要删除学生id:\n");
	    						 read=textField.getText();
	    						 SpringHibernateSessionClient. delectStudent(read);
	    						 StringDAOlistStudents();
	    				          break;
	    					case "4.添加教师":
	    						StringDAOtextArea.appendText("请输入要添加老师姓名:\n");
	    						read=textField.getText();
	    						SpringHibernateSessionClient.newTeacher(read);
	    						StringDAOlistTeachers();
	    			               break;
	    					case "5.修改教师":
	    						StringDAOtextArea.appendText("请输入要修改老师id和姓名:\n");
	    						read=textField.getText();
	    	                    String[] temp1=read.split(" ");
	    	                    SpringHibernateSessionClient.changeTeacher(temp1[0],temp1[1]);
	    	                    StringDAOlistTeachers();
	    	                    break;
	    					case "6.删除教师"	:
	    						StringDAOtextArea.appendText("请输入要删除老师id\n");
	    						read=textField.getText();
	    						SpringHibernateSessionClient.delectTeacher(read);
	    						StringDAOlistTeachers();
	    		                break;
	    					case "7.学生选择指导教师":
	    						StringDAOtextArea.appendText("请输入学生的id和选择老师的id\n");
	    						read=textField.getText();
	    		                   String[] temp2=read.split(" ");
	    		                   SpringHibernateSessionClient.chooseTutorTeacher(temp2[0],temp2[1]);
	    		                   break;
	    					case "8.学生修改指导教师":
	    						StringDAOtextArea.appendText("请输入学生的id和新指导老师的id\n");//not ok
	    						read=textField.getText();
	    	                    String[] temp3=read.split(" ");
	    	                    SpringHibernateSessionClient.changeTutorTeacher(temp3[0]);
	    	                    SpringHibernateSessionClient.chooseTutorTeacher(temp3[0],temp3[1]);
	    			            break;	
	    					case "9.教师选择被指导的学生":
	    						StringDAOtextArea.appendText("请输入老师id和被指导学生id\n");
	    						read=textField.getText();
	    		                   String[] temp4=read.split(" ");
	    		                   SpringHibernateSessionClient.changeBeTutorStudent(temp4[0],temp4[1]);
	    		                   break;
	    					case "10.教师修改被指导的学生":
	    						StringDAOtextArea.appendText("请输入老师id和需要修改被指导学生id\n");
	    						read=textField.getText();
	    	                    String[] temp5=read.split(" ");
	    	                    SpringHibernateSessionClient. changeTutorStudent(temp5[0],temp5[1]);
	    	                    break;
	    					case "11.显示学生和教师信息":
	    						StringDAOlistStudents();
	    						StringDAOlistTeachers();
	    		                break;
	    					}
	    				});
	     AnchorPane.setLeftAnchor(experimentName, 275.0);
		 AnchorPane.setBottomAnchor(experimentName,400.0);//下
		 AnchorPane.setLeftAnchor(textField, 450.0);
		 AnchorPane.setBottomAnchor(textField,350.0);//下
		 AnchorPane.setLeftAnchor( choiceBox, 150.0);
		 AnchorPane.setBottomAnchor( choiceBox,350.0);//下
		 AnchorPane.setLeftAnchor(StringDAOtextArea, 10.0);
		 AnchorPane.setBottomAnchor(StringDAOtextArea,10.0);
		 secondaryStage.setScene(new Scene(anchorPane, 800,450));
		 secondaryStage.show();
    }
    public static void HibernatalistStudents() {
    	HibernatatextArea.appendText("学生名单为：\n");
	    StudentDAO studentDAO=new StudentDAO();
	    List students = studentDAO.findAll();
	    Iterator<?> studentIterator = students.iterator();
	    while(studentIterator.hasNext()){
	    	cn.edu.scau.cmi.liuxintong.Student student = (cn.edu.scau.cmi.liuxintong.Student) studentIterator.next();
	      if(student.getTeacher()!=null) {
	    	  HibernatatextArea.appendText("学生的ID号是："+student.getId()+"学生的名字是："+student.getName()+"学生指导老师"+student.getTeacher().getId());	
	    	  HibernatatextArea.appendText("\n");
	      }
	      else {
	    	  HibernatatextArea.appendText("学生的ID号是："+student.getId()+"学生的名字是："+student.getName()+"学生指导老师"+student.getTeacher());
	    	  HibernatatextArea.appendText("\n");
	      }
	    }
	  }
    public static void HibernatalistTeacher() {
    	HibernatatextArea.appendText("老师名单为：\n");
   	    TeacherDAO teacherDAO=new TeacherDAO();
	    List teachers = teacherDAO.findAll();
	    Iterator<?> teacherIterator = teachers.iterator();
	    while(teacherIterator.hasNext()){
	    	Teacher teacher = (Teacher) teacherIterator.next();
	    	HibernatatextArea.appendText("老师的ID号是："+teacher.getId()+"老师的名字是："+teacher.getName()+"老师指导的学生:");
	      Set students=teacher.getStudents();
	      if(students.size()!=0) {
	    	   for(Object s:students) {//设置该老师指导的学生指导老师为空
	    		   HibernatatextArea.appendText(((Student) s).getId()+" ");
		 }
	      }
	      else HibernatatextArea.appendText("null");
	      HibernatatextArea.appendText("\n");
	    }
	
    }
    public static void StringDAOlistTeachers() {
    	StringDAOtextArea.appendText("老师名单为：\n");
		ApplicationContext ac = ApplicationContextUtil.getSpringHibernateSession();
		TeacherDAO teacherDAO=(TeacherDAO)((BeanFactory) ac).getBean("TeacherDAO");
		List teachers=teacherDAO.findAll();
		Iterator<?> teacherIterator = teachers.iterator();
		 while(teacherIterator.hasNext()){
			 Teacher teacher = (Teacher) teacherIterator.next();
			 StringDAOtextArea.appendText("老师的ID号是："+teacher.getId()+"老师的名字是："+teacher.getName()+"老师指导的学生:");
	 	     Set students=teacher.getStudents();
	 	      if(students.size()!=0) {
	 	    	   for(Object s:students) {//设置该老师指导的学生指导老师为空
	 	    		  StringDAOtextArea.appendText(((Student) s).getId()+" ");
			 }
	 	      }
	 	      else StringDAOtextArea.appendText("null");
	 	     StringDAOtextArea.appendText("\n");
	 	    }
		 }
    public static void StringDAOlistStudents() {
    	StringDAOtextArea.appendText("学生名单为：\n");
		ApplicationContext ac = ApplicationContextUtil.getSpringHibernateSession();
	    StudentDAO studentDAO=(StudentDAO)((BeanFactory) ac).getBean("StudentDAO");
		List students=studentDAO.findAll();
		Iterator<?> studentIterator = students.iterator();
		while(studentIterator.hasNext()){
			cn.edu.scau.cmi.liuxintong.Student student = (cn.edu.scau.cmi.liuxintong.Student) studentIterator.next();
			  if(student.getTeacher()!=null) {
				  StringDAOtextArea.appendText("学生的ID号是："+student.getId()+"学生的名字是："+student.getName()+"学生指导老师"+student.getTeacher().getId()+"\n");	  
		      }
			  else {
				  StringDAOtextArea.appendText("学生的ID号是："+student.getId()+"学生的名字是："+student.getName()+"学生指导老师"+student.getTeacher()+"\n");
		      }
		}
	}
    public static void SpringBaseUselist() {
    	ApplicationContext applicationContext =new ClassPathXmlApplicationContext("applicationContext.xml");
    	cn.edu.scau.cmi.liuxintong.spring.Student student1 = (cn.edu.scau.cmi.liuxintong.spring.Student) applicationContext.getBean("zhangsan");
		 SpringBaseUsetextArea.appendText(student1.getName() + "的毕业设计指导导师是：" + student1.getTeacher().getName());
		 SpringBaseUsetextArea.appendText("\n");
	 }
}
